Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for bedrock/claude3 #781

Merged
merged 7 commits into from
Mar 18, 2024

Conversation

koid
Copy link

@koid koid commented Mar 13, 2024

User description

added support for bedrock/claude3


Type

enhancement, documentation


Description

  • Added support for new Bedrock Claude3 models in the AI handlers.
  • Introduced a new configuration option drop_params to ensure compatibility with Claude3 models.
  • Updated the documentation to guide users on configuring Claude3 models and the new drop_params setting.
  • Updated the litellm library version to 1.31.10 for enhanced functionality and compatibility.

Changes walkthrough

Relevant files
Enhancement
__init__.py
Add Support for Bedrock Claude3 Models                                     

pr_agent/algo/init.py

  • Added support for bedrock/anthropic.claude-3-sonnet-20240229-v1:0 and
    bedrock/anthropic.claude-3-haiku-20240307-v1:0 models.
  • +5/-0     
    litellm_ai_handler.py
    Enhance Litellm AI Handler for Claude3 Compatibility         

    pr_agent/algo/ai_handlers/litellm_ai_handler.py

  • Added condition to drop incompatible parameters when using Claude3
    models.
  • Updated max_tokens for AmazonAnthropicClaude3Config.
  • +3/-0     
    configuration.toml
    Add Drop Params Configuration Option                                         

    pr_agent/settings/configuration.toml

    • Added drop_params configuration option in litellm section.
    +2/-1     
    Documentation
    additional_configurations.md
    Update Documentation for Claude3 Model Configuration         

    docs/docs/usage-guide/additional_configurations.md

  • Updated documentation to include configuration for Claude3 models.
  • Added note on setting drop_params for Claude3 compatibility.
  • +9/-2     
    Dependencies
    requirements.txt
    Update Litellm Library Version                                                     

    requirements.txt

    • Updated litellm library version from 1.29.1 to 1.31.10.
    +1/-1     

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions


    [aws] # in .secrets.toml
    bedrock_region = "us-east-1"
    ```

    Note that you have to add access to foundational models before using them. Please refer to [this document](https://docs.aws.amazon.com/bedrock/latest/userguide/setting-up.html) for more details.

    If you are using the claude-3 model, please configure the following settings as there are parameters incompatible with claude-3.
    Copy link
    Author

    @koid koid Mar 13, 2024

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Copy link
    Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Discussion:
    Another approach could be to set the temperature only if the model is bedrock's claude3 within the chat_completion function.

    @@ -68,6 +70,7 @@ def __init__(self):
    )
    if get_settings().get("AWS.BEDROCK_REGION", None):
    litellm.AmazonAnthropicConfig.max_tokens_to_sample = 2000
    litellm.AmazonAnthropicClaude3Config.max_tokens = 2000
    Copy link
    Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    In litellm, a separate Config class is created for AmazonAnthropicClaude3

    Similar to the following pull request, the value of max_tokens is hardcoded.
    #483 (comment)

    Copy link
    Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Discussion:
    Another approach within chat_completion is to handle which configuration to set based on the model, either AmazonAnthropicConfig or AmazonAnthropicClaude3Config.

    @koid
    Copy link
    Author

    koid commented Mar 13, 2024

    /describe

    1 similar comment
    @koid
    Copy link
    Author

    koid commented Mar 13, 2024

    /describe

    @koid
    Copy link
    Author

    koid commented Mar 13, 2024

    /help

    Copy link
    Contributor

    PR-Agent was enabled for this repository. To use it, please link your git user with your CodiumAI identity here.

    PR Agent Walkthrough

    🤖 Welcome to the PR Agent, an AI-powered tool for automated pull request analysis, feedback, suggestions and more.

    Here is a list of tools you can use to interact with the PR Agent:

    ToolDescriptionInvoke Interactively 💎

    DESCRIBE

    Generates PR description - title, type, summary, code walkthrough and labels
    • Run

    REVIEW

    Adjustable feedback about the PR, possible issues, security concerns, review effort and more
    • Run

    IMPROVE

    Code suggestions for improving the PR.
    • Run

    ANALYZE 💎

    Identifies code components that changed in the PR, and enables to interactively generate tests, docs, and code suggestions for each component.
    • Run

    UPDATE CHANGELOG

    Automatically updates the changelog.
    • Run

    ADD DOCUMENTATION 💎

    Generates documentation to methods/functions/classes that changed in the PR.
    • Run

    ASK

    Answering free-text questions about the PR.

    [*]

    GENERATE CUSTOM LABELS

    Generates custom labels for the PR, based on specific guidelines defined by the user

    [*]

    TEST 💎

    Generates unit tests for a specific component, based on the PR code change.

    [*]

    CI FEEDBACK 💎

    Generates feedback and analysis for a failed CI job.

    [*]

    CUSTOM SUGGESTIONS 💎

    Generates custom suggestions for improving the PR code, based on specific guidelines defined by the user.

    [*]

    SIMILAR ISSUE

    Automatically retrieves and presents similar issues.

    [*]

    (1) Note that each tool be triggered automatically when a new PR is opened, or called manually by commenting on a PR.

    (2) Tools marked with [*] require additional parameters to be passed. For example, to invoke the /ask tool, you need to comment on a PR: /ask "<question content>". See the relevant documentation for each tool for more details.

    @koid
    Copy link
    Author

    koid commented Mar 13, 2024

    /describe

    @codiumai-pr-agent-pro codiumai-pr-agent-pro bot added documentation Improvements or additions to documentation enhancement New feature or request labels Mar 13, 2024
    Copy link
    Contributor

    PR-Agent was enabled for this repository. To use it, please link your git user with your CodiumAI identity here.

    PR Description updated to latest commit (0cdd3bf)

    @koid
    Copy link
    Author

    koid commented Mar 14, 2024

    /describe

    Copy link
    Contributor

    PR-Agent was enabled for this repository. To use it, please link your git user with your CodiumAI identity here.

    PR Description updated to latest commit (3bae515)

    @mrT23
    Copy link
    Collaborator

    mrT23 commented Mar 15, 2024

    Hi @koid , thanks for the PR

    Is the upgrade for litellm version essential for this PR ?
    It sometimes creates problems and conflicts, and I would like to avoid it if possible.
    Otherwise, looks good.

    As a side note, did you form an impression of Claude-3 opus, compared to GPT4, on code? is it competitive ?

    @koid
    Copy link
    Author

    koid commented Mar 18, 2024

    Hi @mrT23 , thanks for review

    The support status for litellm's Claude-3 is as follows, and an update is required.


    I'm sorry, I haven't had the chance to try Claude-3 Opus yet. I plan to try it soon.
    I haven't done a strict comparison, but this is my personal opinion:
    Sonnet is at a usable level and has advantages in terms of cost and response speed.
    I feel that Haiku is at a similar level to GPT-3.5.

    @mrT23
    Copy link
    Collaborator

    mrT23 commented Mar 18, 2024

    PR Review

    ⏱️ Estimated effort to review [1-5]

    2, because the changes are straightforward and mostly involve configuration updates and minor code adjustments. The documentation and requirements update are clear and well-defined.

    🧪 Relevant tests

    No

    🔍 Possible issues

    Possible Bug: The addition of litellm.drop_params in litellm_ai_handler.py without checking its type or existence could lead to runtime errors if not properly configured.

    🔒 Security concerns

    No

    Code feedback:
    relevant filepr_agent/algo/ai_handlers/litellm_ai_handler.py
    suggestion      

    Consider adding a type check for litellm.drop_params to ensure it's a boolean. This prevents potential runtime errors if the configuration is incorrect. [important]

    relevant linelitellm.drop_params = get_settings().litellm.drop_params

    relevant filepr_agent/algo/__init__.py
    suggestion      

    Ensure that the model keys added are consistent and correctly formatted. Double-check for any typos or inconsistencies in model naming conventions. [medium]

    relevant line'bedrock/anthropic.claude-3-sonnet-20240229-v1:0': 100000,

    relevant filedocs/docs/usage-guide/additional_configurations.md
    suggestion      

    Add a note about the expected type for drop_params in the documentation to guide users on proper configuration. [medium]

    relevant linedrop_params = true

    relevant filerequirements.txt
    suggestion      

    Verify the compatibility of the updated litellm library version with the existing codebase to avoid potential integration issues. [important]

    relevant linelitellm==1.31.10


    ✨ Review tool usage guide:

    Overview:
    The review tool scans the PR code changes, and generates a PR review. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
    When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:

    /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
    

    With a configuration file, use the following template:

    [pr_reviewer]
    some_config1=...
    some_config2=...
    
    Utilizing extra instructions

    The review tool can be configured with extra instructions, which can be used to guide the model to a feedback tailored to the needs of your project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify the relevant sub-tool, and the relevant aspects of the PR that you want to emphasize.

    Examples for extra instructions:

    [pr_reviewer] # /review #
    extra_instructions="""
    In the 'possible issues' section, emphasize the following:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    How to enable\disable automation
    • When you first install PR-Agent app, the default mode for the review tool is:
    pr_commands = ["/review", ...]
    

    meaning the review tool will run automatically on every PR, with the default configuration.
    Edit this field to enable/disable the tool, or to change the used configurations

    Auto-labels

    The review tool can auto-generate two specific types of labels for a PR:

    • a possible security issue label, that detects possible security issues (enable_review_labels_security flag)
    • a Review effort [1-5]: x label, where x is the estimated effort to review the PR (enable_review_labels_effort flag)
    Extra sub-tools

    The review tool provides a collection of possible feedbacks about a PR.
    It is recommended to review the possible options, and choose the ones relevant for your use case.
    Some of the feature that are disabled by default are quite useful, and should be considered for enabling. For example:
    require_score_review, require_soc2_ticket, require_can_be_split_review, and more.

    Auto-approve PRs

    By invoking:

    /review auto_approve
    

    The tool will automatically approve the PR, and add a comment with the approval.

    To ensure safety, the auto-approval feature is disabled by default. To enable auto-approval, you need to actively set in a pre-defined configuration file the following:

    [pr_reviewer]
    enable_auto_approval = true
    

    (this specific flag cannot be set with a command line argument, only in the configuration file, committed to the repository)

    You can also enable auto-approval only if the PR meets certain requirements, such as that the estimated_review_effort is equal or below a certain threshold, by adjusting the flag:

    [pr_reviewer]
    maximal_review_effort = 5
    
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the review usage page for a comprehensive guide on using this tool.

    @mrT23 mrT23 merged commit dd83b19 into Codium-ai:main Mar 18, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    documentation Improvements or additions to documentation enhancement New feature or request Review effort [1-5]: 2
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants